package com.huawei.appgallery.assistantdock.gamemode.card;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.huawei.appgallery.assistantdock.buoydock.card.bean.BuoyLanternItem;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import o.aac;
import o.aaf;
import o.beo.f;
import o.beq;
import o.bfs;
import o.bgf;
import o.bgj;
import o.cih;
import o.cii;
import o.Logger;
import o.ezn;
import o.fae;
import o.fam;
import o.ro;
import o.tf;
import o.zp;

public class BuoyLanternEnterCardBuoy extends BuoyBaseEnterCard {
    private Context ʽ;

    public BuoyLanternEnterCardBuoy(Context context) {
        super(context);
        this.ʽ = context;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof BuoyLanternItem) {
            String ˊ = ((BuoyLanternItem) cardBean).ˊ();
            this.ˊ.setText(cardBean.v_());
            ro ˋ = ˋ(this.ʽ, ˊ);
            if (ˋ == null) {
                Logger.e("BuoyLanternEnterCard", "setData error, requestBuilder == null");
            } else {
                ˋ.ˏ(new aac<Drawable>(this, Integer.MIN_VALUE, Integer.MIN_VALUE) {
                    final /* synthetic */ BuoyLanternEnterCardBuoy ˎ;

                    public /* synthetic */ void onResourceReady(@NonNull Object obj, @Nullable aaf o_aaf) {
                        ˊ((Drawable) obj, o_aaf);
                    }

                    public void ˊ(@NonNull Drawable drawable, @Nullable aaf<? super Drawable> o_aaf__super_android_graphics_drawable_Drawable) {
                        this.ˎ.ʼ.setBackground(drawable);
                    }
                });
            }
        }
    }

    private static ro ˋ(Context context, String str) {
        try {
            return Glide.ˏ(context).ᐝ().ˎ(str).ॱ((zp) ((zp) ((zp) new zp().ॱ(true)).ˊ(tf.ˏ)).ॱॱ());
        } catch (IllegalArgumentException e) {
            Logger.ˏ("BuoyLanternEnterCard", "getImageBuilder Glide IllegalArgumentException");
            return null;
        }
    }

    public void ˋ() {
        if (ॱˊ()) {
            bgf.ˊ().ॱ(this.ʼॱ, this.ˊᐝ.ॱॱ());
        } else if (ʻॱ()) {
            ˏॱ();
        } else if (ॱᐝ()) {
            ˊॱ();
        } else if (ͺ()) {
            bgf.ˊ().ˊ(this.ʼॱ, this.ˊᐝ.ॱॱ());
        } else {
            ˋ(this.ʽ, (cih) this);
        }
        if (this.ˊᐝ != null && !TextUtils.isEmpty(this.ˊᐝ.ॱॱ())) {
            beq.ˊ(this.ˊᐝ.ॱॱ());
            beq.ˏ(StartupResponse.CHANNELNO_QUERY_FAILURE, "CLICK", ᐝ(), "DOCK");
        }
    }

    String ᐝ() {
        if (ͺ() || ॱˊ()) {
            return "lantern_forum";
        }
        if (ॱˋ()) {
            return "lantern_gift";
        }
        if (ᐝॱ()) {
            return "lantern_campaign";
        }
        if (ʻॱ()) {
            return "achievement";
        }
        if (ॱᐝ()) {
            return "ranking";
        }
        return this.ˊᐝ.ॱॱ();
    }

    private void ˋ(Context context, cih o_cih) {
        if (o_cih.ˌ() instanceof BaseCardBean) {
            BaseCardBean baseCardBean = (BaseCardBean) o_cih.ˌ();
            if (baseCardBean.ॱॱ() == null || context == null) {
                Logger.ˎ("BuoyLanternEnterCard", "onClick, cardBean: " + baseCardBean + ", context: " + context);
            } else if (!cii.ˊ().ˊ(context, baseCardBean)) {
                ezn.ˊ().ˊ(context.getResources().getString(f.ʻˊ));
                Logger.e("BuoyLanternEnterCard", "onClick, dispatch failed, uri = " + baseCardBean.ॱॱ());
            }
        }
    }

    private void ˏॱ() {
        if (UserSession.getInstance().isLoginSuccessful()) {
            fae ˏ = fam.ॱ().ˏ();
            if (ˏ != null) {
                GameInfo gameInfo = ˏ.getGameInfo();
                if (gameInfo != null) {
                    new bgj().ˊ(this.ʼॱ, gameInfo.getPackageName());
                    return;
                }
                return;
            }
            return;
        }
        bfs.ˋ().ॱ(this.ʼॱ);
    }

    private void ˊॱ() {
        if (UserSession.getInstance().isLoginSuccessful()) {
            fae ˏ = fam.ॱ().ˏ();
            if (ˏ != null) {
                GameInfo gameInfo = ˏ.getGameInfo();
                if (gameInfo != null) {
                    new bgj().ˎ(this.ʼॱ, gameInfo.getPackageName());
                    return;
                }
                return;
            }
            return;
        }
        bfs.ˋ().ॱ(this.ʼॱ);
    }

    private String ˋॱ() {
        if (this.ˊᐝ == null || this.ˊᐝ.ॱॱ() == null) {
            return "";
        }
        String ॱॱ = this.ˊᐝ.ॱॱ();
        int indexOf = ॱॱ.indexOf(124);
        if (indexOf != -1) {
            return ॱॱ.substring(0, indexOf);
        }
        return ॱॱ;
    }

    private boolean ॱˊ() {
        return "forum".equals(ˋॱ());
    }

    private boolean ͺ() {
        return "buoy_forum".equals(ˋॱ());
    }

    private boolean ʻॱ() {
        if (this.ˊᐝ == null) {
            return false;
        }
        Object ॱॱ = this.ˊᐝ.ॱॱ();
        if (TextUtils.isEmpty(ॱॱ)) {
            return false;
        }
        return ॱॱ.startsWith("buoy_client|achievement");
    }

    private boolean ॱᐝ() {
        if (this.ˊᐝ == null) {
            return false;
        }
        Object ॱॱ = this.ˊᐝ.ॱॱ();
        if (TextUtils.isEmpty(ॱॱ)) {
            return false;
        }
        return ॱॱ.startsWith("buoy_client|leaderboard");
    }

    private boolean ॱˋ() {
        if (this.ˊᐝ == null) {
            return false;
        }
        Object ॱॱ = this.ˊᐝ.ॱॱ();
        if (TextUtils.isEmpty(ॱॱ)) {
            return false;
        }
        return ॱॱ.startsWith("buoy_gss|gifts_list");
    }

    private boolean ᐝॱ() {
        if (this.ˊᐝ == null) {
            return false;
        }
        Object ॱॱ = this.ˊᐝ.ॱॱ();
        if (TextUtils.isEmpty(ॱॱ)) {
            return false;
        }
        return ॱॱ.startsWith("buoy_gss|campaign_list");
    }
}
